import React from 'react';
import { Tag } from 'antd';
import { useAssessLevel } from '../../hooks';

export default function AssessTag({ title, onlyText, levels }) {
    const level = useAssessLevel(levels, title);

    let color = '';

    if (level === 3) {
        color = 'green';
    } else if (level === 1) {
        color = 'red';
    }

    const style = onlyText ? { background: 'none', border: 'none' } : {};

    return (
        <Tag color={color} style={style}>
            {title || '待评估'}
        </Tag>
    );
}
